﻿using UnityEngine;
using System.Collections;
namespace UGUIMan
{
    public class SuperPower:MonoBehaviour
    {
        public bool Show;
        public float speed=1;
        private void Update()
        {
            if (Show&&speed>=1)
            {
                transform.position += new Vector3(Time.deltaTime * speed,0,0);
            }
            else if(Show)
            {
                PlayFail();
            }
        }
        float killflag = 0;
        public void Kill()
        {
            Show = false;
            GetComponent<BoxCollider2D>().enabled = false;
            StartCoroutine(killcon());
        }
        IEnumerator killcon()
        {
            yield return new WaitForSeconds(0.01f);
            if (killflag < 0.3f)
            {
                transform.position += new Vector3(0.01f, 0, 0);
                transform.localScale += new Vector3(0.01f, 0.01f, 0);
                StartCoroutine(killcon());
                killflag += 0.01f;
            }
            else
            {
                Destroy(gameObject);
            }
        }
        private void PlayFail()
        {
            
        }
    }
}